-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Using Xunit test output helper in some tests #1362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds XUnit test output helper integration to improve test feedback and logging capabilities. The changes enable tests to capture and output log entries through XUnit's test output mechanism.
- Added new
XUnitLogger
class to bridge .NET logging with XUnit test output - Updated delay scenario test classes across different database providers to accept
ITestOutputHelper
parameter - Modified the base
WorkflowTest
class to integrate the XUnit logger into the dependency injection container
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
src/WorkflowCore.Testing/XUnitLogger.cs | New logger implementation that outputs to XUnit test output helper |
src/WorkflowCore.Testing/WorkflowTest.cs | Updated base test class to integrate XUnit logger and accept test output helper |
src/WorkflowCore.Testing/WorkflowCore.Testing.csproj | Added reference to xunit.abstractions assembly |
test/WorkflowCore.IntegrationTests/Scenarios/DelayScenario.cs | Updated constructor to accept and pass through test output helper |
test/WorkflowCore.Tests.*/Scenarios/*DelayScenario.cs | Updated constructors across database-specific test scenarios to accept test output helper |
Comments suppressed due to low confidence (1)
src/WorkflowCore.Testing/WorkflowCore.Testing.csproj:24
- Using a hard-coded HintPath with absolute path references is fragile and will break on different machines. Consider using a PackageReference instead of a direct assembly reference for better portability and dependency management.
<HintPath>..\..\..\..\..\.nuget\packages\xunit.abstractions\2.0.3\lib\netstandard2.0\xunit.abstractions.dll</HintPath>
|
||
private static string GetLogLevelString(LogLevel logLevel) | ||
{ | ||
return logLevel.ToString().ToUpper(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's trailing whitespace after the semicolon which affects code cleanliness.
return logLevel.ToString().ToUpper(); | |
return logLevel.ToString().ToUpper(); |
Copilot uses AI. Check for mistakes.
services.AddLogging(); | ||
services.AddLogging(l => l.SetMinimumLevel(LogLevel.Trace)); | ||
services.AddSingleton<ILoggerProvider>(p => new XUnitLoggerProvider(testOutputHelper)); | ||
services.Add(ServiceDescriptor.Singleton<ILoggerFactory, LoggerFactory>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicitly registering LoggerFactory as singleton may conflict with the existing logging setup from AddLogging(). The AddLogging() method already registers ILoggerFactory, so this additional registration could cause issues.
services.Add(ServiceDescriptor.Singleton<ILoggerFactory, LoggerFactory>()); | |
// Removed explicit registration of LoggerFactory as singleton for ILoggerFactory to avoid conflict with AddLogging() |
Copilot uses AI. Check for mistakes.
services.AddLogging(l => l.SetMinimumLevel(LogLevel.Trace)); | ||
services.AddSingleton<ILoggerProvider>(p => new XUnitLoggerProvider(testOutputHelper)); | ||
services.Add(ServiceDescriptor.Singleton<ILoggerFactory, LoggerFactory>()); | ||
services.Add(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(XUnitLogger<>))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registering ILogger<> directly may interfere with the logging framework's factory pattern. The ILoggerFactory should be responsible for creating ILogger instances through its CreateLogger method.
services.Add(ServiceDescriptor.Singleton(typeof(ILogger<>), typeof(XUnitLogger<>))); |
Copilot uses AI. Check for mistakes.
Describe the change
This PR is adding logger to capture the log entries for tests and to improve test feedback.
Describe your implementation or design
Added new
XunitLogger
class and addedITestOutputHelper
parameter to some scenario constructors.Tests
No tests are necessary.
Breaking change
No.